// get x() --> x(){...}为当读取属性x时触发的函数

// set x() --> x(){...}为当x重新赋值时触发的函数
// 只有get没有set的属性会被认为是只读的

let  passcode = 'secret passcode'
class  Employee {
  private _fullName: string = ''
  get fullName() {
    return `这是你要的: ${this._fullName}`
  }
  set fullName(newVal: string) {
    if (passcode && passcode === 'secret passcode') {
      this._fullName = newVal
    } else {
      console.log('密码错误');
    }
  }
}
let employee = new Employee()
employee.fullName = '尼古拉斯·赵四'
if (employee.fullName) {
  alert(employee.fullName) // 这是你要的: 尼古拉斯·赵四
}